import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		detail: [{
				id: 1,
				name: '香卤鸡爪',
				average: '30g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
			{
				id: 2,
				name: '香卤牛肚',
				average: '50g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
			{
				id: 3,
				name: '香卤牛肚',
				average: '50g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
			{
				id: 4,
				name: '香卤牛肚',
				average: '50g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
			{
				id: 5,
				name: '香卤牛肚',
				average: '50g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
			{
				id: 6,
				name: '香卤牛肚',
				average: '50g/份',
				collect: false, //是否收藏
				comment1: '月售565',
				comment2: '好评度100%',
				price: 2.7,
				num: 0,
			},
		],

	},
	mutations: {
		add(state, playload) {
			state.detail[playload.arguments.id - 1].num++;
		},
		reduce(state, playload) {
			state.detail[playload.arguments.id - 1].num--;
		},
		love(state, playload) {
			state.detail[playload.arguments.id - 1].collect = !state.detail[playload.arguments.id - 1].collect
		},
		del(state,playload){
			state.detail = state.detail.filter((item) =>{
				return item.id !== playload.arguments.id;
			})
		},
	},
	actions: {}
})

export default store
